package cn.itsource.basic.util.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * 交给spring管理
 */
@Component
public class SendMailService {

    @Autowired
    private JavaMailSender javaMailSender;

    public void send(String title,String text,String to){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人 自己抽常量
        mailMessage.setFrom("772593817@qq.com");
        //邮件主题
        mailMessage.setSubject(title);
        //邮件内容
        mailMessage.setText(text);
        //收件人
        mailMessage.setTo(to);

        javaMailSender.send(mailMessage);
    }
}
